require 'sinatra'
require_relative '../lib/aboutyou-sdk.rb'

get "/doCache" do
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Dalli.new(Dalli::Client.new))
  shop.fetch_facets(["0"])
  return "done"
end

get "/getCache" do
  result = ""
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Dalli.new(Dalli::Client.new))
  
  shop.fetch_facets(["0"]).each do |key, facet|
    result = result + key + '</br>'
  end
  
  return result
end

get "/noCache" do
  result = ""
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Dalli.new(Dalli::Client.new))
  puts shop.cache.delete('AY:SDK:281:facets')
  shop.fetch_facets(["0"]).each do |key, facet|
    result = result + key + '</br>'
  end
  
  return result
end